﻿using Caliburn.Micro;
using MessageLib;

namespace VoiceMessager.ViewModels
{
	public sealed class VerifyViewModel:Screen
	{
		private MainViewModel _mainViewModel;
		private VerifyMethod _verifyMethod;
		public VerifyViewModel(MainViewModel mainViewModel)
		{
			_mainViewModel = mainViewModel;
			RadioNone = _mainViewModel.VerifyMethod == VerifyMethod.None;
			RadioXor = _mainViewModel.VerifyMethod == VerifyMethod.Xor;
			RadioCrc = _mainViewModel.VerifyMethod == VerifyMethod.Crc;
			DisplayName = @"校验方式";
		}

		private bool _radioNone;

		public void ButtonOk()
		{
			_mainViewModel.VerifyMethod = _verifyMethod;
			TryClose();
		}

		public bool RadioNone
		{
			get { return _radioNone; }
			set
			{
				_radioNone = value; 
				NotifyOfPropertyChange();
				if (RadioNone) _verifyMethod = VerifyMethod.None;
			}
		}
		private bool _radioXor;

		public bool RadioXor
		{
			get { return _radioXor; }
			set
			{
				_radioXor = value; 
				NotifyOfPropertyChange();
				if(RadioXor)_verifyMethod = VerifyMethod.Xor;
			}
		}
		private bool _radioCrc;

		public bool RadioCrc
		{
			get { return _radioCrc; }
			set
			{
				_radioCrc = value;
				NotifyOfPropertyChange();
				if(RadioCrc) _verifyMethod = VerifyMethod.Crc;
			}
		}
	}
}
